<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>1.天气案例</title>
		<!-- 引入Vue -->
		<script type="text/javascript" src="../js/vue.js"></script>
	</head>
	<body>
		<!-- 准备好一个容器-->
		<div id="demo">
			<h2>今天天气很：{{weatherText}}</h2>
			<h2>当前a的值是：{{a}}</h2>

			<!-- 下面这行代码，会造成死循环 -->
			<!-- <h2>当前a的值是：{{a++}}</h2> -->

			<button @click="changeWeather">切换天气1</button>
			<button @click="isHot = !isHot">切换天气2</button>
			<button @click="a++">点我让a+1</button>
		</div>

		<script type="text/javascript">
			//阻止 vue 在启动时生成生产提示。
			Vue.config.productionTip = false

			new Vue({
				el:'#demo',
				data:{
					isHot:false,
					a:1
				},
				computed:{
					weatherText(){
						return this.isHot ? '炎热' : '凉爽'
					}
				},
				methods:{
					changeWeather(){
						this.isHot = !this.isHot
					}
				},
				
			})
			
		</script>
	</body>
</html>